package netty;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.core.task.TaskExecutor;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class NettyApplication {
    @Resource
    private NettyServer nettyServer;
    @Resource
    private TaskExecutor taskExecutor;
    public static void main(String[] args) {
        SpringApplication.run(NettyApplication.class,args);
    }
    @PostConstruct
    public void startNetty(){
        taskExecutor.execute(()->{
            nettyServer.setPort(875);
            System.out.println("启动netty");
            nettyServer.start();
        });

    }
}
